package com.example.controller;

import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/v1/api")
@Api("UserController 相关 API")
public class UserController {


    @ApiOperation(value = "查询用户列表", notes = "查询所有用户列表")
    @GetMapping("/users")
    public Object findAll() {
        return "查询列表";
    }


    @ApiOperation(value = "查询用户详情", notes = "根据用户 id 查询用户详情")
    @GetMapping("/user/{id}")
    public Object findById(@ApiParam(name = "用户Id", required = true)
                               @PathVariable("id") Long id) {
        return "查询详情";
    }


    @ApiOperation(value = "分页查询用户列表", notes = "查询所有用户列表（分页查询）")
    @GetMapping("/user/list")
    public Object findList(
            @ApiParam(value = "起始页")
            @RequestParam(name = "pageNum", required = false, defaultValue = "0") Integer pageNum,
            @ApiParam(value = "每页条数", name = "pageSize")
            @RequestParam(name = "pageSize", required = false, defaultValue = "10") Integer pageSize) {

        return "分页查询列表";
    }


    @ApiOperation(value = "分页查询用户列表", notes = "查询所有用户列表（分页查询）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "起始页"),
            @ApiImplicitParam(name = "pageSize", value = "每页条数"),
            @ApiImplicitParam(name = "username", value = "用户名"),
            @ApiImplicitParam(name = "job", value = "职业")
    })
    @GetMapping("/user/list/condition")
    public Object findListByCondition(
            @RequestParam(name = "pageNum", required = false, defaultValue = "0") Integer pageNum,
            @RequestParam(name = "pageSize", required = false, defaultValue = "10") Integer pageSize,
            @RequestParam(name = "username", required = false) String username,
            @RequestParam(name = "job", required = false) String job) {

        return "根据条件分页查询用户列表";
    }

}
